<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">外推模板列表</ui:define>
    <ui:define name="content">


        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:commandButton value="删除全部模板缓存" actionListener="#{extraTemplateListBean.deleteAllTemplateCache()}" icon="fa fa-remove"
                                         process="@this">
                            <p:confirm header="删除缓存" message="确定删除全部缓存？"/>
                        </p:commandButton>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>

                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton value="新增" action="#{extraTemplateListBean.onAdd}"
                                         icon="fa fa-plus"
                                         process="@this" rendered="true">
                            <f:setPropertyActionListener
                                    value="/views/family/extratemplate/extra-template-list.xhtml"
                                    target="#{currentUserBean.back}"/>
                        </p:commandButton>
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         update="@form"/>
                        <p:commandButton value="重置" actionListener="#{extraTemplateListBean.onReset()}" icon="fa fa-refresh"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="模板ID"/>
                        </div>
                        <div class="ui-g-3">
                           <p:inputText id="templateId" value="#{extraTemplateListBean.$.templateId}"/>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="模板名称"/>
                        </div>
                        <div class="ui-g-3">
                            <p:inputText id="templateName" value="#{extraTemplateListBean.$.templateName}"/>
                        </div>
                    </div>


                    <div class="ui-g-12 card">
                        <p:dataTable id="statisticRecordDataTable"
                                     style="width: 100%;text-align:center"
                                     var="record"
                                     value="#{extraTemplateListBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true">
                            <p:column headerText="操作">
                                <p:splitButton icon="fa fa-eye"
                                               process="@this" action="#{extraTemplateListBean.onSee(record.id)}">
                                    <f:setPropertyActionListener
                                            value="/views/family/extratemplate/extra-template-list.xhtml"
                                            target="#{currentUserBean.back}"/>
                                    <p:menuitem value="复制" icon="fa fa-copy"
                                                action="#{extraTemplateListBean.onCopy(record.id)}"
                                                process="@this" update="@form">
                                        <p:confirm header="复制" message="确定复制模板？"/>
                                    </p:menuitem>
                                    <p:menuitem value="删除" icon="fa fa-fw fa-remove"
                                                action="#{extraTemplateListBean.onDelete(record.id)}"
                                                process="@this" update="@form">
                                        <p:confirm header="删除" message="确定删除模板？"/>
                                    </p:menuitem>
                                    <p:menuitem value="删除缓存" icon="fa fa-fw fa-remove"
                                                action="#{extraTemplateListBean.deleteOneTemplateCache(record.templateId)}"
                                                rendered="#{record.templateId != null}"
                                                process="@this" update="@form">
                                        <p:confirm header="删除缓存" message="确定删除缓存？"/>
                                    </p:menuitem>
                                </p:splitButton>
                            </p:column>
                            <p:column headerText="模板ID" style="text-align:center;">
                                <h:outputText value="#{record.templateId}"/>
                            </p:column>
                            <p:column headerText="模板名称" style="text-align:center;">
                                <h:outputText value="#{record.templateName}"/>
                            </p:column>
                            <p:column headerText="创建人" style="text-align:center;">
                                <h:outputText value="#{record.creator}"/>
                            </p:column>
                            <p:column headerText="创建时间" style="text-align:center;">
                                <h:outputText value="#{record.createTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="修改人" style="text-align:center;">
                                <h:outputText value="#{record.updator}"/>
                            </p:column>
                            <p:column headerText="修改时间" style="text-align:center;">
                                <h:outputText value="#{record.updateTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                    </div>

                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>